import router from '@/router'
import $modal from '@/plugins/modal'
import $store from '@/plugins/store'

// 路由前置守卫-登录信息过期检查
router.beforeEach((to, from, next) => {
  const whiteList = ['/login', '/settle', '/success'] // 白名单
  // 加载动态路由
  const token = $store.shop.getAccessToken()
  const menuList = $store.menu.getMenuList()
  if ((token != null && menuList != null) || whiteList.includes(to.path)) {
    next()
  } else {
    $modal.msgError('登录信息已过期！')
    next('/login')
  }
})
